package com.hfcsbc.illegal.parking.car.manager.util;

import org.apache.commons.lang.time.DateUtils;
import org.springframework.util.StringUtils;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * 时间工具类
 * Created by jalen on 17-6-5.
 */
public class DateRangeHandler {

    //将Date类型时间格式转成区间如：2017-06-02 转成 2017-06-02 00:00:00～2017-06-03 00:00:00
    public static Date[] getDateRangeInOneDayWithoutTime(Date date) {
        Date[] dates = new Date[2];
        dates[0] = date;
        Calendar c =Calendar.getInstance();
        c.setTime(date);
        c.add(Calendar.HOUR,24);
        dates[1] = c.getTime();
        return dates;
    }

    public static Date[] getDateRangeInOneDayWithTime(Date date) {
        Date[] dates = new Date[2];
        Date startDate = DateUtils.truncate(new Date(), java.util.Calendar.DAY_OF_MONTH);
        dates[0] = startDate;
        Calendar c =Calendar.getInstance();
        c.setTime(startDate);
        c.add(Calendar.HOUR,24);
        dates[1] = c.getTime();
        return dates;
    }

    public static void main(String[] args) {
        //getDateRangeInOneDayWithoutTime();
    }
}
